#pragma once
#include<fstream>
#include<string>
#include"svpng.inc"
#include<ctime>
void getnow_time(char *src);
void get_random_name(char*filename,bool error)
{
    if(!error)
    {
        strcat(filename,".png");
    }
    else
    {
        strcpy(filename,"../errorimage/image");
        getnow_time(filename);
        strcat(filename,".png");
    }
    
}
void getnow_time(char *src)
{
    time_t rawtime;
    struct tm *info;
    char buffer[50];

    time( &rawtime );

    info = localtime( &rawtime );

    strftime(buffer, 50, "%m-%d %M-%S", info);
    strcat(src,buffer);
   //printf("格式化的日期 & 时间 : |%s|\n", buffer );
}
#include<iostream>
void write(std::string filename,unsigned char rgb[],int w,int h)
{
    unsigned char  *p = rgb;
    unsigned x, y;
    FILE *fp = fopen(filename.c_str(), "wb");
    if (fp == NULL)
	{
        std::cout<<filename;
		std::cout<<"error";
        fclose(fp);
        return;
	}
    svpng(fp, w, h, rgb, 0);
    fclose(fp);
};